import request from '@/utils/request.js'

export const userLogin = ({ username, password }) =>
  request.post('/user/login', { username, password })

// 获取指定角色的用户列表
export const getRoleInfo = (role) => request.get(`/user/getRoleInfo/${role}`)

// 获取用户信息
export const getUserInfo = (userId) => request.get(`/user/getInfo/${userId}`);


// 添加用户
export const addUserToBackend = ({ username, password, role, departmentId }) =>
  request.post('/user/addpeople', { username, password, role, departmentId })


// 获取用户数据
export const fetchUsers = (params) => {
  return request.get('/user/getUsersInfo', { params })
}


// 删除用户
export const deleteUserFromBackend = (id) =>
  request.delete(`/user/delete/${id}`)

// 获取本部门员工信息
export const getEmployeeInfo = () => request.get('/user/getEmployeeInfo')


//修改用户信息
export const updateUserToBackend = (params) => 
  request.put(`/user/update`, params)

//验证密码
export const verifyPassword = ({ password }) =>
  request.post('/user/verifyPassword', { password })


//更改用户的头像
// api/user.js
export const userUpdateAvatarService = (formData) =>
  request.put('/user/update/avatar', formData)


